/*
 * Copyright (c) 2012 Jonathan Tyers
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package uk.org.uplink.configproxy;

/**
 * Provides common patterns for use with the {@code @}{@link ConfigValue} <tt>patterns</tt> attribute.
 * 
 * @author jonny
 */
public class Patterns {
	/**
	 * Special pattern processed by config-proxy. Using this pattern will cause config-proxy to auto-select
	 * a pattern based on the return type of the method.
	 */
	public static final String AUTO = new String();

	/**
	 * Matches a number without a decimal place.
	 */
	public static final String INTEGER = "^\\d+$";

	/**
	 * Matches a number, optionally with a decimal place.
	 */
	public static final String DECIMAL = "^\\d+(\\.\\d+)?$";

	/**
	 * Matches "true" or "false".
	 */
	public static final String BOOLEAN = "^true|false$";

	/**
	 * Matches any string (including a zero-length string).
	 */
	public static final String ANYTHING = ".*";

	/**
	 * Matches IPv4 addresses. Any address from 0.0.0.0 to 255.255.255.255 is accepted.
	 */
	public static final String IP_ADDR = "^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";

	/**
	 * Matches email addresses.
	 */
	public static final String EMAIL_ADDRESS = "^[\\w\\._%\\+\\-]+@[\\w\\.\\-]+\\.[\\w]+$";
}
